/***************************************************************
 *
 * (c) 2008 Markus Dittrich 
 *
 * This program is free software; you can redistribute it 
 * and/or modify it under the terms of the GNU General Public 
 * License Version 3 as published by the Free Software Foundation. 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License Version 3 for more details.
 *
 * You should have received a copy of the GNU General Public 
 * License along with this program; if not, write to the Free 
 * Software Foundation, Inc., 59 Temple Place - Suite 330, 
 * Boston, MA 02111-1307, USA.
 *
 ****************************************************************/

#ifndef DATALABELMANAGER_H
#define DATALABELMANAGER_H

/** STL includes */
#include <map>
#include <list>

/* Qt includes */
#include <QPoint>
#include <QString>

/* define "macro" for type of label */
const int MAIN_LABEL = 0;
const int X_AXIS_LABEL = 1;
const int Y_AXIS_LABEL = 2;
const int DATA_LABEL = 3;


/*****************************************************************
 *
 * DataLabelManager manages the axis labels, per data set labels,
 * as well as the main canvas label; 
 *
 *****************************************************************/
class DataLabelManager
{

public:

  explicit DataLabelManager();

  /* getter and setter functions */
  void set_label_name(int label, QString labelName);
  void set_label_pos(int label, QPoint position, 
      bool setAsDefault = false);
  void set_label_dim(int label, QSizeF position);
  const QString& get_axis_label(int label) const;
  const QPoint& get_label_pos(int label) const;

  void set_data_label_name(QString name, QString labelName);
  const std::map<QString,QString>& get_data_labels() const;
  QString get_data_label(QString dataName);

  /* functions for changing positions of labels
   * on the canvas */
  void move_label_left(int label);
  void move_label_right(int label);
  void move_label_up(int label);
  void move_label_down(int label);
  void reset_label(int label);

  /* getter and setter functions for data set labels */
  void add_data_set(QString name);
  void remove_data_set(QString name);
  const std::list<QString>& get_data_label_names() const;


private:

  /* no copy and assignments semantics */
  DataLabelManager(const DataLabelManager&);
  const DataLabelManager& operator= (const DataLabelManager&);

  /* data members */
  QString MainLabel_;
  QPoint MainLabelPos_;
  QPoint MainLabelDefaultPos_;

  QString XAxisLabel_;
  QPoint XAxisLabelPos_;
  QPoint XAxisLabelDefaultPos_;

  QString YAxisLabel_;
  QPoint YAxisLabelPos_;
  QPoint YAxisLabelDefaultPos_;

  QPoint DataLabelsPos_;
  QPoint DataLabelsDefaultPos_;
  std::map<QString,QString> DataLabels_;

  /* label related data */
  std::list<QString> DataNames_;

  /* static data members */
  const static QString EmptyString_;
  const static QPoint Origin_;
  const static int LabelShiftSize_ = 5;    // in pixels
};

#endif
